home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / roids / roids.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  4.4 KB  |  188 lines

  1. /*
  2.  * Copyright 1989 Digital Equipment Corporation
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and its
  5.  * documentation for any purpose and without fee is hereby granted,
  6.  * provided that the above copyright notice appear in all copies and that
  7.  * both that copyright notice and this permission notice appear in
  8.  * supporting documentation, and that the name of Digital Equipment
  9.  * Corporation not be used in advertising or publicity pertaining to
  10.  * distribution of the software without specific, written prior
  11.  * permission.  Digital Equipment Corporation makes no representations
  12.  * about the suitability of this software for any purpose.  It is
  13.  * provided "as is" without express or implied warranty.
  14.  *
  15.  * DIGITAL EQUIPMENT CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO
  16.  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17.  * FITNESS, IN NO EVENT SHALL DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR
  18.  * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  20.  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  21.  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * Author:  Terry Weissman
  24.  *          weissman@decwrl.dec.com
  25.  */
  26.  
  27. /* roids.h - definitions of roids data structures. */
  28.  
  29. #ifndef _roids_h
  30. #define _roids_h
  31.  
  32. #include <stdio.h>
  33. #include <math.h>
  34. #include <X11/Xlib.h>
  35. #include <X11/Xos.h>
  36.  
  37. #include <X11/Xutil.h>
  38. #include <X11/cursorfont.h>
  39.  
  40. #include <X11/IntrinsicP.h>
  41. #include <X11/StringDefs.h>
  42.  
  43. #define XtRFloat "Float"
  44. #define rint(x) ((int) (x))
  45. #define MIN(x, y)    ((x) < (y) ? (x) : (y))
  46. #define MAX(x, y)    ((x) > (y) ? (x) : (y))
  47. #define NPOINTS 3        /* Number of points on a ship. */
  48.  
  49. #ifndef M_PI
  50. #define    M_PI    3.14159265358979323846
  51. #define    M_PI_2    1.57079632679489661923
  52. #define    M_PI_4    0.78539816339744830962
  53. #endif
  54.  
  55. #ifdef MAIN
  56. #define ext
  57. #else
  58. #define ext extern
  59. #endif
  60.  
  61. /*
  62.  * Definitions to make us act as a widget.
  63.  */
  64.  
  65. /* New fields for the Roids widget class record */
  66. typedef struct {
  67.      int mumble;   /* No new procedures */
  68. } RoidsClassPart;
  69.  
  70. /* Full class record declaration */
  71. typedef struct _RoidsClassRec {
  72.     CoreClassPart       core_class;
  73.     RoidsClassPart    roids_class;
  74. } RoidsClassRec;
  75.  
  76. extern RoidsClassRec roidsClassRec;
  77. extern WidgetClass roidsWidgetClass;
  78.  
  79. /* New fields for the Roids widget record */
  80. typedef struct _RoidsPart {
  81.     int dummy;
  82. } RoidsPart;
  83.  
  84.  
  85.  
  86. /* Full instance record declaration */
  87.  
  88. typedef struct _RoidsRec {
  89.     CorePart core;
  90.     RoidsPart roids;
  91. } RoidsRec, *RoidsWidget;
  92.  
  93.  
  94.  
  95.  
  96. /*
  97.  * Actual roids definitions.
  98.  */
  99.  
  100. ext Boolean debug;
  101.  
  102. ext Display *dpy;
  103. ext Window gamewindow;
  104. ext RoidsWidget gamewidget;
  105. ext int gamewidth, gameheight;
  106. ext Widget toplevel, scorewidget;
  107. ext int score;
  108. ext int shipsleft;
  109.  
  110. /* Ship info: */
  111.  
  112. ext int shipradius;
  113. ext int numdir;
  114.  
  115. ext int shipwait;        /* Number of milleseconds to wait between */
  116.                 /* moving ship. */
  117. ext int numdestroyed;
  118.  
  119.  
  120.  
  121. ext XtIntervalId shiptimerid;
  122.  
  123. ext Pixel shippixel;
  124. ext float maxv;            /* Constant: what our maximum velocity is. */
  125. ext float accper;        /* Constant: how fast we accelerate. */
  126. ext Boolean shipdestroyed;    /* TRUE if the ship is non-existant */
  127.  
  128. /* Rock info: */
  129.  
  130. ext XtIntervalId rocktimerid;
  131. ext Pixel rockpixel;
  132. ext int rockwait;        /* Number of milleseconds to wait between */
  133.                 /* moving rocks. */
  134. ext float maxrockspeed;        /* Constant: fastest velocity for a rock. */
  135.  
  136. /* Shot info. */
  137.  
  138. ext XtIntervalId shottimerid;
  139. ext Pixel shotpixel;
  140. ext int shotwait;
  141. ext float shotacc;        /* How many times faster a shot goes than */
  142.                 /* the ship.*/
  143. ext int maxshots;        /* How many shots are allowed to exist at */
  144.                 /* once. */
  145. ext int shotduration;        /* How long (in milleseconds) a shot lives. */
  146.  
  147.  
  148.  
  149.  
  150. ext GC backgc, shipgc, rockgc, shotgc;
  151.  
  152.  
  153.  
  154. /* From widget.c */
  155.  
  156. extern Boolean TakeFocus();
  157. extern void Quit();
  158.  
  159.  
  160.  
  161. /* From ship.c */
  162.  
  163. extern void MoveShip();
  164. extern void ThrustOn();
  165. extern void ThrustOff();
  166. extern void RotateLeft();
  167. extern void RotateRight();
  168. extern void RotateOff();
  169. extern void RotateToPoint();
  170. extern void StopRotateToPoint();
  171. extern void RotateMouseMoved();
  172. extern void Fire();
  173.  
  174. /* From rocks.c */
  175.  
  176. extern Boolean CheckIfShipHitRocks();
  177. extern Boolean AreaForShipIsClear();
  178. extern Boolean LineHitsRock();
  179. extern void MoveRocks();
  180. extern void InitRocks();
  181.  
  182. /* From shot.c */
  183.  
  184. extern void AddShot();
  185. extern void MoveShots();
  186.  
  187. #endif _roids_h
  188.